/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.mortbay.jetty.pico.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Hnmtuan
 */
@Entity
@Table(name = "category")
@NamedQueries({
    @NamedQuery(name = "Category.findAll", query = "SELECT c FROM Category c"),
    @NamedQuery(name = "Category.findByIdCate", query = "SELECT c FROM Category c WHERE c.idCate = :idCate"),
    @NamedQuery(name = "Category.findByCateName", query = "SELECT c FROM Category c WHERE c.cateName = :cateName"),
    @NamedQuery(name = "Category.findByCateDescription", query = "SELECT c FROM Category c WHERE c.cateDescription = :cateDescription"),
    @NamedQuery(name = "Category.findByCateState", query = "SELECT c FROM Category c WHERE c.cateState = :cateState"),
    @NamedQuery(name = "Category.findByCateIcon", query = "SELECT c FROM Category c WHERE c.cateIcon = :cateIcon")})
public class Category implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "idCate")
    private String idCate;
    @Column(name = "CateName")
    private String cateName;
    @Column(name = "CateDescription")
    private String cateDescription;
    @Column(name = "CateState")
    private Integer cateState;
    @Lob
    @Column(name = "CateFields")
    private String cateFields;
    @Column(name = "CateIcon")
    private String cateIcon;
    @OneToMany(mappedBy = "category")
    private List<Category> categoryList;
    @JoinColumn(name = "CateParent", referencedColumnName = "idCate")
    @ManyToOne
    private Category category;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "category1")
    private List<Item> itemList;

    public Category() {
    }

    public Category(String idCate) {
        this.idCate = idCate;
    }

    public String getIdCate() {
        return idCate;
    }

    public void setIdCate(String idCate) {
        this.idCate = idCate;
    }

    public String getCateName() {
        return cateName;
    }

    public void setCateName(String cateName) {
        this.cateName = cateName;
    }

    public String getCateDescription() {
        return cateDescription;
    }

    public void setCateDescription(String cateDescription) {
        this.cateDescription = cateDescription;
    }

    public Integer getCateState() {
        return cateState;
    }

    public void setCateState(Integer cateState) {
        this.cateState = cateState;
    }

    public String getCateFields() {
        return cateFields;
    }

    public void setCateFields(String cateFields) {
        this.cateFields = cateFields;
    }

    public String getCateIcon() {
        return cateIcon;
    }

    public void setCateIcon(String cateIcon) {
        this.cateIcon = cateIcon;
    }

    public List<Category> getCategoryList() {
        return categoryList;
    }

    public void setCategoryList(List<Category> categoryList) {
        this.categoryList = categoryList;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    public List<Item> getItemList() {
        return itemList;
    }

    public void setItemList(List<Item> itemList) {
        this.itemList = itemList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCate != null ? idCate.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Category)) {
            return false;
        }
        Category other = (Category) object;
        if ((this.idCate == null && other.idCate != null) || (this.idCate != null && !this.idCate.equals(other.idCate))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.mortbay.jetty.pico.entities.Category[idCate=" + idCate + "]";
    }

}
